package com.ayf.payment.game.api.mapper;

import com.ayf.payment.game.api.dto.ReissueRecordDTO;
import com.ayf.payment.game.api.dto.ReissueRecordVO;
import com.ayf.payment.game.api.dto.criteria.CleanCriteria;
import com.ayf.payment.game.api.dto.criteria.ReissueRecordSelectCriteria;
import com.ayf.payment.game.api.dto.platform.MerchantReissueRecordDTO;
import com.ayf.payment.game.api.dto.platform.criteria.MerchantReissueRecordCriteria;
import com.ayf.payment.game.api.entity.ReissueRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface ReissueRecordMapper extends Mapper<ReissueRecord> {

    public List<ReissueRecordDTO> selectByPage(@Param("selectCriteria") ReissueRecordSelectCriteria selectCriteria);

    /**
     * 查询补发总金额
     *
     * @param selectCriteria
     * @return
     */
    ReissueRecordVO selectTotalAmountByPage(@Param("selectCriteria") ReissueRecordSelectCriteria selectCriteria);

    public List<MerchantReissueRecordDTO> selectMerchantReissueRecordByPage(@Param("selectCriteria") MerchantReissueRecordCriteria selectCriteria);

    public ReissueRecord selectById(@Param("merchantId") Integer merchantId, @Param("reissueId") String reissueId);

    //更新整区补发订单
    @Update("update g_reissue_record set script_status=#{scriptStatus} where rat_id=#{ratId}")
    public void updateReissueAllTask(@Param("ratId") String ratId, @Param("scriptStatus") int scriptStatus);

    //更新整区补发订单
    @Update("update g_reissue_record set script_status=#{scriptStatus} where rat_id=#{ratId} and script_status=2")
    public void updateReissueAllTasks(@Param("ratId") String ratId, @Param("scriptStatus") int scriptStatus);

    //修改整区后补状态
    @Update("update g_reissue_record set script_status=1 where serial_number in (#{serialNumbers})")
    public void updateWholeReplacement(@Param("serialNumbers") String serialNumbers);

    //修改手动充值后补状态
    @Update("update g_reissue_record set script_status=#{scriptStatus} where serial_number = #{serialNumbers}")
    public void updateManualReplacement(@Param("serialNumbers") String serialNumbers, @Param("scriptStatus") int scriptStatus);

    public void delByIds(@Param("Ids") String[] Ids);

    /**
     * 清理补发记录
     *
     * @param clean
     * @return
     */
    int cleanReissueRecord(@Param("clean") CleanCriteria clean);
}